

public class NO3 {
	
	public static boolean duplicate(int[] a){
		int temp = 0 ;
		if(a.length <=0 ){
			return false;
		}
		for(int i = 0 ; i < a.length ; i++ ){
			if(a[i] < 0 || a[i] > a.length-1)
				return false ;
		}
		
		for(int i = 0 ; i < a.length ; i++){
			while(a[i]!= i){
				if(a[i] == a[a[i]]){
					System.out.println(a[i]);
					return true ;
				}
				temp = a[a[i]] ;
				a[a[i]]  = a[i] ;
				a[i] = temp ;
			}
		}
		
		
		return true;
	}
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//int[] a = {2,3,1,0,2,5,3};
		//int[] a = {2,1,3,1,4};
		//int[] a = {2,4,3,1,4};
		int[] a = {2,4,3,1,5};
		duplicate(a);
		System.out.println("done");
	}

}
